package com.horsecoder.im.common.protocol.context.chain.response;

import com.horsecoder.common.status.Status;
import com.horsecoder.im.common.protocol.BaseMessage;
import com.horsecoder.im.common.protocol.context.chain.request.Request;
import com.horsecoder.im.common.protocol.convert.support.RequestResponseConverter;

import java.util.Map;
import java.util.UUID;

/**
 * Author: Zhu yuhan
 * Email: zhuyuhan2333@qq.com
 * Date: 2022/3/16 11:19 上午
 **/
public class Response extends BaseMessage {

    private Status statusCode;

    private Request request;

    public Response() {
    }

    public Response(Request request) {
        RequestResponseConverter.convert(request, this);
        setId(UUID.randomUUID().toString().substring(0, 32).replace("-", ""));
    }

    public Response(String id, String type, String messageType, String message, String identity, String receiver, String url, Status statusCode, Request request) {
        super(id, type, messageType, message, identity, receiver, url);
        this.statusCode = statusCode;
        this.request = request;
    }

    public Response(String id, String type, String messageType, String message, String identity, String receiver, String url, Map<String, String> metadata, Status statusCode, Request request) {
        super(id, type, messageType, message, identity, receiver, url, metadata);
        this.statusCode = statusCode;
        this.request = request;
    }

    public Status getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Status statusCode) {
        this.statusCode = statusCode;
    }

    public Request getRequest() {
        return request;
    }

    public void setRequest(Request request) {
        this.request = request;
    }

}